package cn.lanqiao.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


/**
 * @author Heroleaves
 */
@Controller
public class HelloController {
    @RequestMapping("/")
    public String index() {
        //返回试图名称
        return "index";
    }

    @RequestMapping("/target")
    public String toTarget() {
        return "target";
    }

    @RequestMapping(value = "/test", method = {RequestMethod.POST})
    public String test() {
        return "success";
    }

    @GetMapping("/testGetMapping")
    public String testGetMapping() {
        return "success";
    }

    @RequestMapping(value = "/testPut", method = {RequestMethod.PUT})
    public String testPut() {
        return "success";
    }

    @RequestMapping(value = "/testParams", params = {
            "!username"
    })
    public String testParams() {
        return "success";
    }

    @RequestMapping(
            value = "/testHeaders",
            params = {"username"},
            headers = {"Host=localhost:8081"}
    )
    public String testHeaders() {
        return "success";
    }

    /**
     *  * 多个字符
     */
    @RequestMapping(value = "/a?a/testAnt")
    public String testAnt() {
        return "success";
    }

    @RequestMapping(value = "/testPath/{id}")
    public String testPath(@PathVariable("id") Integer id) {
        System.out.println(id);
        return "success";
    }

}